var app = getApp();
var host = 'https://www.lythds.com/';
// var host = 'http://acbkshoptest.com/';
let token = app.globalData.token || wx.getStorageSync('token');
function request({
	url,
	token,
	data = {},
	method = 'GET'
}) {
	return new Promise(function (resolve, reject) {
		_request(url, resolve, reject, token, data, method)
	})
}

function _request(url, resolve, reject, token, data = {}, method = 'GET') {
	wx.request({
		url: host + url,
		header: {
			'token': token || ''
		},
		data: data,
		method: method,
		success: res => {
			resolve(res)
		},
		fail: () => {
			reject('接口请求失败')
		},
		complete: () => {
			wx.hideLoading();
		}
	})
}



function checkToken(token){
  if(!token){
    console.log("!token")
  }
}



module.exports = {
	request
}
// global.Object = Object
// global.Array = Array
// global.Buffer = Buffer
// global.DataView = DataView
// global.Date = Date
// global.Error = Error
// global.Float32Array = Float32Array
// global.Float64Array = Float64Array
// global.Function = Function
// global.Int8Array = Int8Array
// global.Int16Array = Int16Array
// global.Int32Array = Int32Array
// global.Map = Map
// global.Math = Math
// global.Promise = Promise
// global.RegExp = RegExp
// global.Set = Set
// global.String = String
// global.Symbol = Symbol
// global.TypeError = TypeError
// global.Uint8Array = Uint8Array
// global.Uint8ClampedArray = Uint8ClampedArray
// global.Uint16Array = Uint16Array
// global.Uint32Array = Uint32Array
// global.WeakMap = WeakMap
// global.clearTimeout = clearTimeout
// global.isFinite = isFinite
// global.parseInt = parseInt
// global.setTimeout = setTimeout